// 防抖
export const debounce = (() => {
  let timer: number = 0
  return (callback: any, wait: any) => {
    clearTimeout(timer)
    timer = setTimeout(callback, wait)
  }
})()

// 验证密码 - 请输入6 ~ 14位,数字/字母/下划线/-
export const isPassword = (val: string) => {
  return /^[a-zA-Z0-9_-]{6,20}$/.test(val)
}

// 验证用户名 - 姓名不能有数字
export const isName = (val: string) => {
  return /^[^\d]*$/.test(val)
}

// 验证手机号 - 请输入正确的手机号
export const isPhone = (val: string) => {
  return /^1(3|4|5|7|8|9)\d{9}$/.test(val)
}

// 验证账号 - 账号不能输入汉字
export const isAccount = (val: string) => {
  return /^[^\u4e00-\u9fa5]+$/.test(val)
}
